package com.javatest;

import java.math.BigDecimal;
import java.util.Scanner;

/**
 * @author LL
 * 获得任意一个正整数的阶乘
 * @create 2020-12-10 17:22
 */
public class Subject14 {

    public static void factorial(int a){
        int sum = 1;
        String str = "";
        for (int j = 1; j <= a; j++) {
            sum = sum*j;
            if (j == 1) {
                str = str + j;
            }else{
                str = str +"*"+j;
            }
        }
        System.out.println(a+"的阶乘为：" + str + "="+sum);
    }

    public static void main(String[] args) {
        System.out.println("输入一个正整数：");
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        factorial(i);
    }
}
